package com.wanlian.common;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringMatchUtil {
    public static boolean isEmail() {
        String str = "service@xsoftlab.net";
        String regEx = "[a-zA-Z_]{1,}[0-9]{0,}@(([a-zA-z0-9]-*){1,}\\.){1,3}[a-zA-z\\-]{1,}";
        Pattern pattern = Pattern.compile(regEx);
        Matcher matcher = pattern.matcher(str);
        boolean rs = matcher.matches();
        return rs;
    }

    public static boolean isNum(String sourcestr) {
        String regEx = "^(-?\\d+)(\\.\\d+)?$";
        Pattern pattern = Pattern.compile(regEx);
        Matcher matcher = pattern.matcher(sourcestr);
        boolean rs = matcher.matches();
        return rs;
    }

    public static boolean isFloat(String sourcestr) {
        String regEx = "^(-?\\d+)(\\.\\d+)?$";
        Pattern pattern = Pattern.compile(regEx);
        Matcher matcher = pattern.matcher(sourcestr);
        boolean rs = matcher.matches();
        return rs;
    }

    public static boolean isDate(String sourcestr) {
        String checkValue = sourcestr;
        String eL = "^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))";
        Pattern p = Pattern.compile(eL);
        Matcher m = p.matcher(checkValue);
        boolean b = m.matches();
        return b;
    }

    public static boolean isInt(String sourcestr) {
        String regEx = "^-?\\d+$";
        Pattern pattern = Pattern.compile(regEx);
        Matcher matcher = pattern.matcher(sourcestr);
        boolean rs = matcher.matches();
        return rs;
    }

    public static boolean isweixin(String sourcestr) {
        String regEx = "^[a-zA-Z]{1}[-_a-zA-Z0-9]{5,19}$";
        Pattern pattern = Pattern.compile(regEx);
        Matcher matcher = pattern.matcher(sourcestr);
        boolean rs = matcher.matches();
        return rs;
    }

    public static boolean isDigit(String strNum) {
        return strNum.matches("[0-9]{1,}");
    }

    public static void main(String[] args) {

        System.out.println(isDigit("000011313022"));
    }

}
